<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template vector</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.Compute">
<link rel="up" href="../../boost_compute/reference.html#header.boost.compute.container.vector_hpp" title="Header &lt;boost/compute/container/vector.hpp&gt;">
<link rel="prev" href="../../BOOST_CO_idm45822166410816.html" title="Macro BOOST_COMPUTE_DEFINE_VALARRAY_LOGICAL_OPERATOR">
<link rel="next" href="context_error.html" title="Class context_error">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../BOOST_CO_idm45822166410816.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_compute/reference.html#header.boost.compute.container.vector_hpp"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="context_error.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.compute.vector"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template vector</span></h2>
<p>boost::compute::vector — A resizable array of values. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../boost_compute/reference.html#header.boost.compute.container.vector_hpp" title="Header &lt;boost/compute/container/vector.hpp&gt;">boost/compute/container/vector.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">typename</span> Alloc <span class="special">=</span> <a class="link" href="buffer_allocator.html" title="Class template buffer_allocator">buffer_allocator</a><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span> <span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">T</span>                                       <a name="boost.compute.vector.value_type"></a><span class="identifier">value_type</span><span class="special">;</span>            
  <span class="keyword">typedef</span> <span class="identifier">Alloc</span>                                   <a name="boost.compute.vector.allocator_type"></a><span class="identifier">allocator_type</span><span class="special">;</span>        
  <span class="keyword">typedef</span> <span class="identifier">allocator_type</span><span class="special">::</span><span class="identifier">size_type</span>               <a name="boost.compute.vector.size_type"></a><span class="identifier">size_type</span><span class="special">;</span>             
  <span class="keyword">typedef</span> <span class="identifier">allocator_type</span><span class="special">::</span><span class="identifier">difference_type</span>         <a name="boost.compute.vector.difference_type"></a><span class="identifier">difference_type</span><span class="special">;</span>       
  <span class="keyword">typedef</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span>                             <a name="boost.compute.vector.reference"></a><span class="identifier">reference</span><span class="special">;</span>             
  <span class="keyword">typedef</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span>                             <a name="boost.compute.vector.const_reference"></a><span class="identifier">const_reference</span><span class="special">;</span>       
  <span class="keyword">typedef</span> <span class="identifier">allocator_type</span><span class="special">::</span><span class="identifier">pointer</span>                 <a name="boost.compute.vector.pointer"></a><span class="identifier">pointer</span><span class="special">;</span>               
  <span class="keyword">typedef</span> <span class="identifier">allocator_type</span><span class="special">::</span><span class="identifier">const_pointer</span>           <a name="boost.compute.vector.const_pointer"></a><span class="identifier">const_pointer</span><span class="special">;</span>         
  <span class="keyword">typedef</span> <a class="link" href="buffer_iterator.html" title="Class template buffer_iterator">buffer_iterator</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span>                    <a name="boost.compute.vector.iterator"></a><span class="identifier">iterator</span><span class="special">;</span>              
  <span class="keyword">typedef</span> <a class="link" href="buffer_iterator.html" title="Class template buffer_iterator">buffer_iterator</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span>                    <a name="boost.compute.vector.const_iterator"></a><span class="identifier">const_iterator</span><span class="special">;</span>        
  <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">reverse_iterator</span><span class="special">&lt;</span> <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <span class="special">&gt;</span>       <a name="boost.compute.vector.reverse_iterator"></a><span class="identifier">reverse_iterator</span><span class="special">;</span>      
  <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">reverse_iterator</span><span class="special">&lt;</span> <a class="link" href="vector.html#boost.compute.vector.const_iterator">const_iterator</a> <span class="special">&gt;</span> <a name="boost.compute.vector.const_reverse_iterator"></a><span class="identifier">const_reverse_iterator</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="vector.html#boost.compute.vectorconstruct-copy-destruct">construct/copy/destruct</a></span>
  <span class="keyword">explicit</span> <a class="link" href="vector.html#idm45822166278080-bb"><span class="identifier">vector</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">context</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_context</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">explicit</span> <a class="link" href="vector.html#idm45822166275776-bb"><span class="identifier">vector</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">context</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_context</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#idm45822166270208-bb"><span class="identifier">vector</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> InputIterator<span class="special">&gt;</span> 
    <a class="link" href="vector.html#idm45822166265120-bb"><span class="identifier">vector</span></a><span class="special">(</span><span class="identifier">InputIterator</span><span class="special">,</span> <span class="identifier">InputIterator</span><span class="special">,</span> 
           <span class="identifier">command_queue</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#idm45822166258640-bb"><span class="identifier">vector</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OtherAlloc<span class="special">&gt;</span> 
    <a class="link" href="vector.html#idm45822166255472-bb"><span class="identifier">vector</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="vector.html" title="Class template vector">vector</a><span class="special">&lt;</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">OtherAlloc</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span> 
           <span class="identifier">command_queue</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OtherAlloc<span class="special">&gt;</span> 
    <a class="link" href="vector.html#idm45822166251456-bb"><span class="identifier">vector</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">OtherAlloc</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span> 
           <span class="identifier">command_queue</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#idm45822166247872-bb"><span class="identifier">vector</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">initializer_list</span><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span><span class="special">,</span> 
         <span class="identifier">command_queue</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#idm45822166238640-bb"><span class="identifier">vector</span></a><span class="special">(</span><a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> <a class="link" href="vector.html#idm45822166245904-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OtherAlloc<span class="special">&gt;</span> 
    <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> <a class="link" href="vector.html#idm45822166243904-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="vector.html" title="Class template vector">vector</a><span class="special">&lt;</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">OtherAlloc</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OtherAlloc<span class="special">&gt;</span> 
    <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> <a class="link" href="vector.html#idm45822166241056-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">OtherAlloc</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> <a class="link" href="vector.html#idm45822166236624-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#idm45822166233584-bb"><span class="special">~</span><span class="identifier">vector</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="vector.html#idm45822166381536-bb">public member functions</a></span>
  <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a class="link" href="vector.html#idm45822166380976-bb"><span class="identifier">begin</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.const_iterator">const_iterator</a> <a class="link" href="vector.html#idm45822166380000-bb"><span class="identifier">begin</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.const_iterator">const_iterator</a> <a class="link" href="vector.html#idm45822166378752-bb"><span class="identifier">cbegin</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a class="link" href="vector.html#idm45822166377504-bb"><span class="identifier">end</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.const_iterator">const_iterator</a> <a class="link" href="vector.html#idm45822166376528-bb"><span class="identifier">end</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.const_iterator">const_iterator</a> <a class="link" href="vector.html#idm45822166375280-bb"><span class="identifier">cend</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">reverse_iterator</span> <a class="link" href="vector.html#idm45822166374032-bb"><span class="identifier">rbegin</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">const_reverse_iterator</span> <a class="link" href="vector.html#idm45822166373184-bb"><span class="identifier">rbegin</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">const_reverse_iterator</span> <a class="link" href="vector.html#idm45822166372064-bb"><span class="identifier">crbegin</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">reverse_iterator</span> <a class="link" href="vector.html#idm45822166370944-bb"><span class="identifier">rend</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">const_reverse_iterator</span> <a class="link" href="vector.html#idm45822166370096-bb"><span class="identifier">rend</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">const_reverse_iterator</span> <a class="link" href="vector.html#idm45822166368976-bb"><span class="identifier">crend</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">size_type</span> <a class="link" href="vector.html#idm45822166367856-bb"><span class="identifier">size</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">size_type</span> <a class="link" href="vector.html#idm45822166366416-bb"><span class="identifier">max_size</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166365296-bb"><span class="identifier">resize</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166362336-bb"><span class="identifier">resize</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="vector.html#idm45822166360256-bb"><span class="identifier">empty</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">size_type</span> <a class="link" href="vector.html#idm45822166358384-bb"><span class="identifier">capacity</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166356960-bb"><span class="identifier">reserve</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166354736-bb"><span class="identifier">reserve</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166353200-bb"><span class="identifier">shrink_to_fit</span></a><span class="special">(</span><span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166351664-bb"><span class="identifier">shrink_to_fit</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">reference</span> <a class="link" href="vector.html#idm45822166350816-bb"><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">const_reference</span> <a class="link" href="vector.html#idm45822166349280-bb"><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">reference</span> <a class="link" href="vector.html#idm45822166347472-bb"><span class="identifier">at</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">const_reference</span> <a class="link" href="vector.html#idm45822166345936-bb"><span class="identifier">at</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">reference</span> <a class="link" href="vector.html#idm45822166344128-bb"><span class="identifier">front</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">const_reference</span> <a class="link" href="vector.html#idm45822166343280-bb"><span class="identifier">front</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">reference</span> <a class="link" href="vector.html#idm45822166342160-bb"><span class="identifier">back</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">const_reference</span> <a class="link" href="vector.html#idm45822166341312-bb"><span class="identifier">back</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> InputIterator<span class="special">&gt;</span> 
    <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166340192-bb"><span class="identifier">assign</span></a><span class="special">(</span><span class="identifier">InputIterator</span><span class="special">,</span> <span class="identifier">InputIterator</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> InputIterator<span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166336432-bb"><span class="identifier">assign</span></a><span class="special">(</span><span class="identifier">InputIterator</span><span class="special">,</span> <span class="identifier">InputIterator</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166333360-bb"><span class="identifier">assign</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166330448-bb"><span class="identifier">assign</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166328224-bb"><span class="identifier">push_back</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166323232-bb"><span class="identifier">push_back</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166321152-bb"><span class="identifier">pop_back</span></a><span class="special">(</span><span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166319616-bb"><span class="identifier">pop_back</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a class="link" href="vector.html#idm45822166318768-bb"><span class="identifier">insert</span></a><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a class="link" href="vector.html#idm45822166315600-bb"><span class="identifier">insert</span></a><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166313120-bb"><span class="identifier">insert</span></a><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">,</span> <span class="identifier">size_type</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166309392-bb"><span class="identifier">insert</span></a><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">,</span> <span class="identifier">size_type</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> InputIterator<span class="special">&gt;</span> 
    <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166306352-bb"><span class="identifier">insert</span></a><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">,</span> <span class="identifier">InputIterator</span><span class="special">,</span> <span class="identifier">InputIterator</span><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> InputIterator<span class="special">&gt;</span> 
    <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166299552-bb"><span class="identifier">insert</span></a><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">,</span> <span class="identifier">InputIterator</span><span class="special">,</span> <span class="identifier">InputIterator</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a class="link" href="vector.html#idm45822166295120-bb"><span class="identifier">erase</span></a><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a class="link" href="vector.html#idm45822166292640-bb"><span class="identifier">erase</span></a><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a class="link" href="vector.html#idm45822166290848-bb"><span class="identifier">erase</span></a><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">,</span> <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a class="link" href="vector.html#idm45822166287552-bb"><span class="identifier">erase</span></a><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">,</span> <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166284944-bb"><span class="identifier">swap</span></a><span class="special">(</span><a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="vector.html#idm45822166281936-bb"><span class="identifier">clear</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">allocator_type</span> <a class="link" href="vector.html#idm45822166280784-bb"><span class="identifier">get_allocator</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">const</span> <span class="identifier">buffer</span> <span class="special">&amp;</span> <a class="link" href="vector.html#idm45822166279664-bb"><span class="identifier">get_buffer</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idm46604978171904"></a><h2>Description</h2>
<p>The <a class="link" href="vector.html" title="Class template vector">vector&lt;T&gt;</a> class stores a dynamic array of values. Internally, the data is stored in an OpenCL buffer object.</p>
<p>The vector class is the prefered container for storing and accessing data on a compute device. In most cases it should be used instead of directly dealing with buffer objects. If the undelying buffer is needed, it can be accessed with the get_buffer() method.</p>
<p>The internal storage is allocated in a specific OpenCL context which is passed as an argument to the constructor when the vector is created.</p>
<p>For example, to create a vector on the device containing space for ten <code class="computeroutput">int</code> values: </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">vec</span><span class="special">(</span><span class="number">10</span><span class="special">,</span> <span class="identifier">context</span><span class="special">)</span><span class="special">;</span>
</pre>
<p>Allocation and data transfer can also be performed in a single step: </p>
<pre class="programlisting"><span class="comment">// values on the host</span>
<span class="keyword">int</span> <span class="identifier">data</span><span class="special">[</span><span class="special">]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">,</span> <span class="number">4</span> <span class="special">}</span><span class="special">;</span>

<span class="comment">// create a vector of size four and copy the values from data</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">vec</span><span class="special">(</span><span class="identifier">data</span><span class="special">,</span> <span class="identifier">data</span> <span class="special">+</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">queue</span><span class="special">)</span><span class="special">;</span>
</pre>
<p>The Boost.Compute <code class="computeroutput">vector</code> class provides a STL-like API and is modeled after the <code class="computeroutput">std::vector</code> class from the C++ standard library. It can be used with any of the STL-like algorithms provided by Boost.Compute including <code class="computeroutput">copy()</code>, <code class="computeroutput">transform()</code>, and <code class="computeroutput">sort()</code> (among many others).</p>
<p>For example: </p>
<pre class="programlisting"><span class="comment">// a vector on a compute device</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;</span> <span class="identifier">vec</span> <span class="special">=</span> <span class="special">...</span>

<span class="comment">// copy data to the vector from a host std:vector</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span><span class="identifier">host_vec</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">host_vec</span><span class="special">.</span><span class="identifier">end</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">vec</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">queue</span><span class="special">)</span><span class="special">;</span>

<span class="comment">// copy data from the vector to a host std::vector</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span><span class="identifier">vec</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">vec</span><span class="special">.</span><span class="identifier">end</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">host_vec</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">queue</span><span class="special">)</span><span class="special">;</span>

<span class="comment">// sort the values in the vector</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">sort</span><span class="special">(</span><span class="identifier">vec</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">vec</span><span class="special">.</span><span class="identifier">end</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">queue</span><span class="special">)</span><span class="special">;</span>

<span class="comment">// calculate the sum of the values in the vector (also see reduce())</span>
<span class="keyword">float</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">accumulate</span><span class="special">(</span><span class="identifier">vec</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">vec</span><span class="special">.</span><span class="identifier">end</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">queue</span><span class="special">)</span><span class="special">;</span>

<span class="comment">// reverse the values in the vector</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">reverse</span><span class="special">(</span><span class="identifier">vec</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">vec</span><span class="special">.</span><span class="identifier">end</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">queue</span><span class="special">)</span><span class="special">;</span>

<span class="comment">// fill the vector with ones</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">fill</span><span class="special">(</span><span class="identifier">vec</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">vec</span><span class="special">.</span><span class="identifier">end</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">queue</span><span class="special">)</span><span class="special">;</span>
</pre>
<p><span class="bold"><strong>See Also:</strong></span></p>
<p><a class="link" href="array.html" title="Class template array">array&lt;T, N&gt;</a>, buffer </p>
<p>
</p>
<p>
</p>
<div class="refsect2">
<a name="idm46604978037952"></a><h3>
<a name="boost.compute.vectorconstruct-copy-destruct"></a><code class="computeroutput">vector</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="idm45822166278080-bb"></a><span class="identifier">vector</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">context</span> <span class="special">&amp;</span> context <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_context</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>Creates an empty vector in <code class="computeroutput">context</code>. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="idm45822166275776-bb"></a><span class="identifier">vector</span><span class="special">(</span><span class="identifier">size_type</span> count<span class="special">,</span> 
                <span class="keyword">const</span> <span class="identifier">context</span> <span class="special">&amp;</span> context <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_context</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>
<p>Creates a vector with space for <code class="computeroutput">count</code> elements in <code class="computeroutput">context</code>.</p>
<p>Note that unlike <code class="computeroutput">std::vector's</code> constructor, this will not initialize the values in the container. Either call the vector constructor which takes a value to initialize with or use the fill() algorithm to set the initial values.</p>
<p>For example: </p>
<pre class="programlisting"><span class="comment">// create a vector on the device with space for ten ints</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">vec</span><span class="special">(</span><span class="number">10</span><span class="special">,</span> <span class="identifier">context</span><span class="special">)</span><span class="special">;</span>
</pre>
<p> </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idm45822166270208-bb"></a><span class="identifier">vector</span><span class="special">(</span><span class="identifier">size_type</span> count<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span> value<span class="special">,</span> 
       <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>
<p>Creates a vector with space for <code class="computeroutput">count</code> elements and sets each equal to <code class="computeroutput">value</code>.</p>
<p>For example: </p>
<pre class="programlisting"><span class="comment">// creates a vector with four values set to nine (e.g. [9, 9, 9, 9]).</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">vec</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="number">9</span><span class="special">,</span> <span class="identifier">queue</span><span class="special">)</span><span class="special">;</span>
</pre>
<p> </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> InputIterator<span class="special">&gt;</span> 
  <a name="idm45822166265120-bb"></a><span class="identifier">vector</span><span class="special">(</span><span class="identifier">InputIterator</span> first<span class="special">,</span> <span class="identifier">InputIterator</span> last<span class="special">,</span> 
         <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>
<p>Creates a vector with space for the values in the range [<code class="computeroutput">first</code>, <code class="computeroutput">last</code>) and copies them into the vector with <code class="computeroutput">queue</code>.</p>
<p>For example: </p>
<pre class="programlisting"><span class="comment">// values on the host</span>
<span class="keyword">int</span> <span class="identifier">data</span><span class="special">[</span><span class="special">]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">,</span> <span class="number">4</span> <span class="special">}</span><span class="special">;</span>

<span class="comment">// create a vector of size four and copy the values from data</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">compute</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">vec</span><span class="special">(</span><span class="identifier">data</span><span class="special">,</span> <span class="identifier">data</span> <span class="special">+</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">queue</span><span class="special">)</span><span class="special">;</span>
</pre>
<p> </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idm45822166258640-bb"></a><span class="identifier">vector</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> other<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>Creates a new vector and copies the values from <code class="computeroutput">other</code>. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OtherAlloc<span class="special">&gt;</span> 
  <a name="idm45822166255472-bb"></a><span class="identifier">vector</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="vector.html" title="Class template vector">vector</a><span class="special">&lt;</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">OtherAlloc</span> <span class="special">&gt;</span> <span class="special">&amp;</span> other<span class="special">,</span> 
         <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>Creates a new vector and copies the values from <code class="computeroutput">other</code>. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OtherAlloc<span class="special">&gt;</span> 
  <a name="idm45822166251456-bb"></a><span class="identifier">vector</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">OtherAlloc</span> <span class="special">&gt;</span> <span class="special">&amp;</span> vector<span class="special">,</span> 
         <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>Creates a new vector and copies the values from <code class="computeroutput">vector</code>. </li>
<li class="listitem"><pre class="literallayout"><a name="idm45822166247872-bb"></a><span class="identifier">vector</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">initializer_list</span><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> list<span class="special">,</span> 
       <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue <span class="special">=</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">default_queue</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><a name="idm45822166238640-bb"></a><span class="identifier">vector</span><span class="special">(</span><a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>Move-constructs a new vector from <code class="computeroutput">other</code>. </li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> <a name="idm45822166245904-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OtherAlloc<span class="special">&gt;</span> 
  <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> <a name="idm45822166243904-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="vector.html" title="Class template vector">vector</a><span class="special">&lt;</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">OtherAlloc</span> <span class="special">&gt;</span> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> OtherAlloc<span class="special">&gt;</span> 
  <a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> <a name="idm45822166241056-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">OtherAlloc</span> <span class="special">&gt;</span> <span class="special">&amp;</span> vector<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> <a name="idm45822166236624-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>Move-assigns the data from <code class="computeroutput">other</code> to <code class="computeroutput">*this</code>. </li>
<li class="listitem">
<pre class="literallayout"><a name="idm45822166233584-bb"></a><span class="special">~</span><span class="identifier">vector</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Destroys the vector object. </li>
</ol></div>
</div>
<div class="refsect2">
<a name="idm46604977820672"></a><h3>
<a name="idm45822166381536-bb"></a><code class="computeroutput">vector</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a name="idm45822166380976-bb"></a><span class="identifier">begin</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.const_iterator">const_iterator</a> <a name="idm45822166380000-bb"></a><span class="identifier">begin</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.const_iterator">const_iterator</a> <a name="idm45822166378752-bb"></a><span class="identifier">cbegin</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a name="idm45822166377504-bb"></a><span class="identifier">end</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.const_iterator">const_iterator</a> <a name="idm45822166376528-bb"></a><span class="identifier">end</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.const_iterator">const_iterator</a> <a name="idm45822166375280-bb"></a><span class="identifier">cend</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">reverse_iterator</span> <a name="idm45822166374032-bb"></a><span class="identifier">rbegin</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">const_reverse_iterator</span> <a name="idm45822166373184-bb"></a><span class="identifier">rbegin</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">const_reverse_iterator</span> <a name="idm45822166372064-bb"></a><span class="identifier">crbegin</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">reverse_iterator</span> <a name="idm45822166370944-bb"></a><span class="identifier">rend</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">const_reverse_iterator</span> <a name="idm45822166370096-bb"></a><span class="identifier">rend</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">const_reverse_iterator</span> <a name="idm45822166368976-bb"></a><span class="identifier">crend</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">size_type</span> <a name="idm45822166367856-bb"></a><span class="identifier">size</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns the number of elements in the vector. </li>
<li class="listitem"><pre class="literallayout"><span class="identifier">size_type</span> <a name="idm45822166366416-bb"></a><span class="identifier">max_size</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166365296-bb"></a><span class="identifier">resize</span><span class="special">(</span><span class="identifier">size_type</span> size<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre>Resizes the vector to <code class="computeroutput">size</code>. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166362336-bb"></a><span class="identifier">resize</span><span class="special">(</span><span class="identifier">size_type</span> size<span class="special">)</span><span class="special">;</span></pre>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="idm45822166360256-bb"></a><span class="identifier">empty</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns <code class="computeroutput">true</code> if the vector is empty. </li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">size_type</span> <a name="idm45822166358384-bb"></a><span class="identifier">capacity</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns the capacity of the vector. </li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166356960-bb"></a><span class="identifier">reserve</span><span class="special">(</span><span class="identifier">size_type</span> size<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166354736-bb"></a><span class="identifier">reserve</span><span class="special">(</span><span class="identifier">size_type</span> size<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166353200-bb"></a><span class="identifier">shrink_to_fit</span><span class="special">(</span><span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166351664-bb"></a><span class="identifier">shrink_to_fit</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">reference</span> <a name="idm45822166350816-bb"></a><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span><span class="special">(</span><span class="identifier">size_type</span> index<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">const_reference</span> <a name="idm45822166349280-bb"></a><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span><span class="special">(</span><span class="identifier">size_type</span> index<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">reference</span> <a name="idm45822166347472-bb"></a><span class="identifier">at</span><span class="special">(</span><span class="identifier">size_type</span> index<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">const_reference</span> <a name="idm45822166345936-bb"></a><span class="identifier">at</span><span class="special">(</span><span class="identifier">size_type</span> index<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">reference</span> <a name="idm45822166344128-bb"></a><span class="identifier">front</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">const_reference</span> <a name="idm45822166343280-bb"></a><span class="identifier">front</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">reference</span> <a name="idm45822166342160-bb"></a><span class="identifier">back</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">const_reference</span> <a name="idm45822166341312-bb"></a><span class="identifier">back</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> InputIterator<span class="special">&gt;</span> 
  <span class="keyword">void</span> <a name="idm45822166340192-bb"></a><span class="identifier">assign</span><span class="special">(</span><span class="identifier">InputIterator</span> first<span class="special">,</span> <span class="identifier">InputIterator</span> last<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> InputIterator<span class="special">&gt;</span> 
  <span class="keyword">void</span> <a name="idm45822166336432-bb"></a><span class="identifier">assign</span><span class="special">(</span><span class="identifier">InputIterator</span> first<span class="special">,</span> <span class="identifier">InputIterator</span> last<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166333360-bb"></a><span class="identifier">assign</span><span class="special">(</span><span class="identifier">size_type</span> n<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span> value<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166330448-bb"></a><span class="identifier">assign</span><span class="special">(</span><span class="identifier">size_type</span> n<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span> value<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166328224-bb"></a><span class="identifier">push_back</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span> value<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre>
<p>Inserts <code class="computeroutput">value</code> at the end of the vector (resizing if neccessary).</p>
<p>Note that calling <code class="computeroutput">push_back()</code> to insert data values one at a time is inefficient as there is a non-trivial overhead in performing a data transfer to the device. It is usually better to store a set of values on the host (for example, in a <code class="computeroutput">std::vector</code>) and then transfer them in bulk using the <code class="computeroutput">insert()</code> method or the copy() algorithm. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166323232-bb"></a><span class="identifier">push_back</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span> value<span class="special">)</span><span class="special">;</span></pre>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>
</li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166321152-bb"></a><span class="identifier">pop_back</span><span class="special">(</span><span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166319616-bb"></a><span class="identifier">pop_back</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a name="idm45822166318768-bb"></a><span class="identifier">insert</span><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> position<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span> value<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a name="idm45822166315600-bb"></a><span class="identifier">insert</span><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> position<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span> value<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166313120-bb"></a><span class="identifier">insert</span><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> position<span class="special">,</span> <span class="identifier">size_type</span> count<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span> value<span class="special">,</span> 
            <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166309392-bb"></a><span class="identifier">insert</span><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> position<span class="special">,</span> <span class="identifier">size_type</span> count<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span> value<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> InputIterator<span class="special">&gt;</span> 
  <span class="keyword">void</span> <a name="idm45822166306352-bb"></a><span class="identifier">insert</span><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> position<span class="special">,</span> <span class="identifier">InputIterator</span> first<span class="special">,</span> <span class="identifier">InputIterator</span> last<span class="special">,</span> 
              <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre>
<p>Inserts the values in the range [<code class="computeroutput">first</code>, <code class="computeroutput">last</code>) into the vector at <code class="computeroutput">position</code> using <code class="computeroutput">queue</code>. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> InputIterator<span class="special">&gt;</span> 
  <span class="keyword">void</span> <a name="idm45822166299552-bb"></a><span class="identifier">insert</span><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> position<span class="special">,</span> <span class="identifier">InputIterator</span> first<span class="special">,</span> <span class="identifier">InputIterator</span> last<span class="special">)</span><span class="special">;</span></pre>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p>
</li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a name="idm45822166295120-bb"></a><span class="identifier">erase</span><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> position<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a name="idm45822166292640-bb"></a><span class="identifier">erase</span><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> position<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a name="idm45822166290848-bb"></a><span class="identifier">erase</span><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> first<span class="special">,</span> <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> last<span class="special">,</span> <span class="identifier">command_queue</span> <span class="special">&amp;</span> queue<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> <a name="idm45822166287552-bb"></a><span class="identifier">erase</span><span class="special">(</span><a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> first<span class="special">,</span> <a class="link" href="vector.html#boost.compute.vector.iterator">iterator</a> last<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166284944-bb"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="vector.html" title="Class template vector">vector</a> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>Swaps the contents of <code class="computeroutput">*this</code> with <code class="computeroutput">other</code>. </li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45822166281936-bb"></a><span class="identifier">clear</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Removes all elements from the vector. </li>
<li class="listitem"><pre class="literallayout"><span class="identifier">allocator_type</span> <a name="idm45822166280784-bb"></a><span class="identifier">get_allocator</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">const</span> <span class="identifier">buffer</span> <span class="special">&amp;</span> <a name="idm45822166279664-bb"></a><span class="identifier">get_buffer</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Returns the underlying buffer. </li>
</ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2013, 2014 Kyle Lutz<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../BOOST_CO_idm45822166410816.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_compute/reference.html#header.boost.compute.container.vector_hpp"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="context_error.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
